package com.ruoyi.procurementmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.procurementmanagement.domain.EsSpecValues;
import com.ruoyi.procurementmanagement.service.IEsSpecValuesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 规格值Controller
 * 
 * @author ruoyi
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/procurementmanagement/values")
public class EsSpecValuesController extends BaseController
{
    @Autowired
    private IEsSpecValuesService esSpecValuesService;

    /**
     * 查询规格值列表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:list')")
    @GetMapping("/list")
    public TableDataInfo list(EsSpecValues esSpecValues)
    {
        startPage();
        List<EsSpecValues> list = esSpecValuesService.selectEsSpecValuesList(esSpecValues);
        return getDataTable(list);
    }

    /**
     * 导出规格值列表
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:export')")
    @Log(title = "规格值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EsSpecValues esSpecValues)
    {
        List<EsSpecValues> list = esSpecValuesService.selectEsSpecValuesList(esSpecValues);
        ExcelUtil<EsSpecValues> util = new ExcelUtil<EsSpecValues>(EsSpecValues.class);
        util.exportExcel(response, list, "规格值数据");
    }

    /**
     * 获取规格值详细信息
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:query')")
    @GetMapping(value = "/{specValueId}")
    public AjaxResult getInfo(@PathVariable("specValueId") Long specValueId)
    {
        return success(esSpecValuesService.selectEsSpecValuesBySpecValueId(specValueId));
    }

    /**
     * 新增规格值
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:add')")
    @Log(title = "规格值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EsSpecValues esSpecValues)
    {
        return toAjax(esSpecValuesService.insertEsSpecValues(esSpecValues));
    }

    /**
     * 修改规格值
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:edit')")
    @Log(title = "规格值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EsSpecValues esSpecValues)
    {
        return toAjax(esSpecValuesService.updateEsSpecValues(esSpecValues));
    }

    /**
     * 删除规格值
     */
    @PreAuthorize("@ss.hasPermi('procurementmanagement:values:remove')")
    @Log(title = "规格值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{specValueIds}")
    public AjaxResult remove(@PathVariable Long[] specValueIds)
    {
        return toAjax(esSpecValuesService.deleteEsSpecValuesBySpecValueIds(specValueIds));
    }
}
